//安装时默认启用
chrome.runtime.onInstalled.addListener(() => {
    chrome.storage.local.set({
        Enabled: true,      //启用扩展
        Auto_expand: false, //自动展开
        Enable_copy: true,  //破解复制
        Clear_doms: true,   //清除弹窗和无用组件
    }, () => {
        console.log('OK: Extension is installed!');
    });
});

//监听tab页面加载，匹配CSDN
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
    if (/blog.csdn.net/.test(tab.url) && /article/.test(tab.url) && changeInfo.status === "complete") {
        chrome.scripting.executeScript({
            target: {
                tabId: tabId
            },
            files: ["./content-script.js"],
        }).then(() => {
            console.log("INJECTED SCRIPT SUCC.");
        }).catch((err) => console.log(err));
    }
});